package com.blade.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class BaseController {
    @Autowired
    HttpServletRequest request;

    HttpServletResponse response;

    @ModelAttribute
    protected void setResponse(HttpServletRequest request, HttpServletResponse response) {
        // ModelAttribute注解表示执行本类的每个action，应该就是请求方法前，都会先执行这个方法
        this.request = request;
        this.response = response;
        // 这样请求和响应对象就可以直接使用了，试了下request支持@AutoWr...注解，但是response不知道
        // 暂时不知道为啥
    }
}
